package edu.exp3.model;

import java.util.ArrayList;

public class Teacher extends Person {
    // 教师的授课列表
    private ArrayList<Course> teachings = new ArrayList<Course>();

    public Teacher(String id, String name, Gender gender) {
        super(id, name, gender); // super() 初始化父类字段
    }

    /** 教师开课：创建课程并登记到自己的授课列表 */
    public Course openCourse(String cid, String name, String place,
                             String time, double credit, int capacity) {
        Course c = new Course(cid, name, place, time, credit, capacity, this);
        teachings.add(c);
        return c;
    }

    public ArrayList<Course> getTeachings() {
        return new ArrayList<Course>(teachings);
    }

    @Override
    public void printWorkSheet() {
        System.out.println("=== 教师工作单 ===");
        System.out.println(baseInfo()); // 复用父类受保护方法
        if (teachings.isEmpty()) {
            System.out.println("暂无授课任务");
        } else {
            for (Course c : teachings) {
                System.out.println("授课课程：" + c.getName());
                System.out.println("上课地点：" + c.getPlace());
                System.out.println("上课时间：" + c.getTime());
                System.out.println("已选人数：" + c.getStudents().size() + "/" + c.getCapacity());
                System.out.println("---");
            }
        }
    }
}
